from redis import StrictRedis
import logging


class Config(object):
    """封装配置的类"""
    DEBUG = True

    SQLALCHEMY_DATABASE_URI = 'mysql://root:mysql@127.0.0.1:3306/sql'
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379
    # 准备秘钥
    SECRET_KEY = 'HBC'

    # 配置Session:将Session数据引导到redis
    # 指定存储Session数据的数据库类型为redis
    SESSION_TYPE = 'redis'
    # 指定Session的存储位置
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    # 开启Session数据的签名，混淆
    SESSION_USE_SIGNER = True
    # 设置Session有效期，混淆
    PERMANENT_SESSION_LIFETIME = 3600 * 24


class DevelopmentConfig(Config):
    """开发模式下"""
    DEBUG = True
    LOGGING_LEVEL = logging.DEBUG


class ProductionConfig(Config):
    """生产模式下"""
    DEBUG = False
    LOGGING_LEVEL = logging.WARNING


configs = {
    'dev': DevelopmentConfig,
    'prod': ProductionConfig

}
